{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\Carolina\OneDrive\Documentos\@ - UT Austin\Co-Authoring\Equation Balance - CW and PE\Replication Files - Final - Feb 2021\log_numerical_results_appendix1.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res} 9 Feb 2021, 19:38:24

{com}. do "C:\Users\Carolina\AppData\Local\Temp\STD00000000.tmp"
{txt}
{com}. 
. 
. clear all
{txt}
{com}. *Set version of stata
. version 14.2
{txt}
{com}. 
. *seed randomly generated by: https://www.random.org/ (b/t 1 and 1000000000)
. set seed 24205253
{txt}
{com}. 
. *Generate datafile to save results:
. *PATH NEEDS TO BE UPDATED
. cd "C:\Users\Carolina\OneDrive\Documentos\@ - UT Austin\Co-Authoring\Equation Balance - CW and PE\Replication Files - Final - Feb 2021" 
{res}C:\Users\Carolina\OneDrive\Documentos\@ - UT Austin\Co-Authoring\Equation Balance - CW and PE\Replication Files - Final - Feb 2021
{txt}
{com}. tempname pfile
{txt}
{com}. tempfile lrmfile
{txt}
{com}. postfile `pfile' str20(variable) lrm se_lrm t using "`lrmfile'"
{txt}
{com}. 
. *generate 5,000 datasets
. forvalues i=1/5000 {c -(}
{txt}  2{com}.         drop _all
{txt}  3{com}. *1st 200 obs will be dropped, T=5,000
. quietly set obs 5200
{txt}  4{com}. quietly gen t = _n
{txt}  5{com}. quietly tsset t
{txt}  6{com}. *All variables are I(1)
. *only x and y are related. x2-x9 are unrelated to y
. quietly gen x = rnormal() if t==1
{txt}  7{com}. quietly replace x=l.x + rnormal() if t>1
{txt}  8{com}. quietly gen x2 = rnormal() if t==1
{txt}  9{com}. quietly replace x2=l.x2 + rnormal() if t>1
{txt} 10{com}. quietly gen x3 = rnormal() if t==1
{txt} 11{com}. quietly replace x3=l.x3 + rnormal() if t>1
{txt} 12{com}. quietly gen x4 = rnormal() if t==1
{txt} 13{com}. quietly replace x4=l.x4 + rnormal() if t>1
{txt} 14{com}. quietly gen x5 = rnormal() if t==1
{txt} 15{com}. quietly replace x5=l.x5 + rnormal() if t>1
{txt} 16{com}. quietly gen x6 = rnormal() if t==1
{txt} 17{com}. quietly replace x6=l.x6 + rnormal() if t>1
{txt} 18{com}. quietly gen x7 = rnormal() if t==1
{txt} 19{com}. quietly replace x7=l.x7 + rnormal() if t>1
{txt} 20{com}. quietly gen x8 = rnormal() if t==1
{txt} 21{com}. quietly replace x8=l.x8 + rnormal() if t>1
{txt} 22{com}. quietly gen x9 = rnormal() if t==1
{txt} 23{com}. quietly replace x9=l.x9 + rnormal() if t>1
{txt} 24{com}. quietly gen g = rnormal() if t==1
{txt} 25{com}. quietly replace g = .6*l.g + rnormal() if t>1
{txt} 26{com}. quietly gen y = x + g
{txt} 27{com}. 
. ******************************
. **Generate lagged variable for each predictor w/ long run effect
. ******************************
. foreach x in y x x2 x3 x4 x5 x6 x7 x8 x9 {c -(}
{txt} 28{com}. quietly gen l_`x' = l.`x'
{txt} 29{com}. {c )-}
{txt} 30{com}. *************
. 
. *drop 1st 200 observations to ensure starting value doesn't
. *influence results
. quietly drop if t<=200
{txt} 31{com}. 
. **Must include lagged values before differenced values, so correct elements of the vce are called
. quietly reg d.y l_y l_x l_x2 l_x3 l_x4 l_x5 l_x6 l_x7 l_x8 l_x9 d.x d.x2 d.x3 d.x4 d.x5 d.x6 d.x7 d.x8 d.x9 
{txt} 32{com}. matrix vcov =e(V)
{txt} 33{com}. 
. *gen local variable of value 1
. local i = 1
{txt} 34{com}. *loop over variables for which we will calculate a long term effect
. foreach x in l_x l_x2 l_x3 l_x4 l_x5 l_x6 l_x7 l_x8 l_x9 {c -(}
{txt} 35{com}. quietly sum `x' if e(sample)
{txt} 36{com}. local lrm = _b[`x']/abs(_b[l_y])
{txt} 37{com}. local selrm = sqrt(((1/(_b[l_y]^2))*(_se[`x']^2))+((_b[`x']^2)/(_b[l_y]^4)*(_se[l_y]^2))-(2*(_b[`x']/(_b[l_y]^3))*(vcov[(`i'+1),1])))
{txt} 38{com}. *add 1 to i each loop, so appropriate element of vcov is identified.
. local i = `i' + 1
{txt} 39{com}. post `pfile'  ("`x'") (`lrm') (`selrm') (`lrm'/`selrm') 
{txt} 40{com}. {c )-}
{txt} 41{com}. {c )-}
{txt}
{com}. 
. 
. postclose `pfile'
{txt}
{com}. use "`lrmfile'", clear
{txt}
{com}. 
. 
. *identify spurious relationsips for x2-x9
. sum t if abs(t)>1.96 & variable != "l_x"

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 11}t {c |}{res}      2,072    .0054639    2.370674  -4.734475   3.791513
{txt}
{com}. *save # spurious LRMs
. scalar sig = r(N)
{txt}
{com}. 
. *identify total simulations for this group
. sum t if variable != "l_x"

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 11}t {c |}{res}     40,000    -.007365    1.009774  -4.734475   3.791513
{txt}
{com}. scalar total = r(N)
{txt}
{com}. 
. *identify percent of spurious LRMs
. scalar spurious = 100*sig/total
{txt}
{com}. di spurious
{res}5.18
{txt}
{com}. 
. *identify mean lrm for unrelated predictors (x2-x9)
. sum lrm if variable != "l_x"

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 9}lrm {c |}{res}     40,000   -.0000219    .0032551  -.0225559   .0146908
{txt}
{com}. 
. 
. ***********************************
. ***********************************
. ***********************************
. ***********************************
. 
. 
. 
{txt}end of do-file

{com}. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\Carolina\OneDrive\Documentos\@ - UT Austin\Co-Authoring\Equation Balance - CW and PE\Replication Files - Final - Feb 2021\log_numerical_results_appendix1.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res} 9 Feb 2021, 19:46:24
{txt}{.-}
{smcl}
{txt}{sf}{ul off}